package com.project.srtp.secure.util;
import org.springframework.http.HttpStatus;
import org.springframework.web.server.ResponseStatusException;

import java.io.PrintWriter;
import java.io.StringWriter;

/**
 * @author 曹行阳
 * @version 0.1
 * @date 2025/6/10 16:53
 * 统一异常工具
 */
public class ExceptionUtil {

    public static ResponseStatusException toResponseStatusException(String message, HttpStatus status) {
        return new ResponseStatusException(status, message);
    }

    public static String getStackTrace(Throwable t) {
        StringWriter sw = new StringWriter();
        t.printStackTrace(new PrintWriter(sw));
        return sw.toString();
    }
}
